luci-mod-network: diagnostics: add realtime command output
authorRichard Yu <[email protected]>
Mon, 1 Sep 2025 14:43:16 +0000 (22:43 +0800)
committerPaul Donald <[email protected]>
Fri, 12 Dec 2025 15:40:04 +0000 (16:40 +0100)
The diagnostics page is using `fs.exec()` to execute command, which blocks
until command exit. Users have to wait for a while to see the result.

When doing IPv6 traceroute, this may cause XHR timeout, if target host
is unreachable. (See issue #7210)

This commit uses new `responseProgress` callback and `stderr` option
added in luci.js and fs.js to update command output.

Signed-off-by: Richard Yu <[email protected]>
Link: https://github.com/openwrt/luci/pull/7920
modules/luci-mod-network/htdocs/luci-static/resources/view/network/diagnostics.js

index 1bfa95501a82822f72e787a8ff7faf85ff20682f..fa8ae2f64dd30b0877115609cb5ee97d1f2356f0 100644 (file)
@@ -8,15 +8,16 @@
 
 return view.extend({
        handleCommand: function(exec, args) {
-               var buttons = document.querySelectorAll('.diag-action > .cbi-button');
+               var buttons = document.querySelectorAll('.diag-action > .cbi-button'),
+                       out = document.querySelector('textarea');
 
                for (var i = 0; i < buttons.length; i++)
                        buttons[i].setAttribute('disabled', 'true');
 
-               return fs.exec(exec, args).then(function(res) {
-                       var out = document.querySelector('textarea');
-
-                       dom.content(out, [ res.stdout || '', res.stderr || '' ]);
+               return fs.exec_direct(exec, args, 'text', false, true, function(ev) {
+                       out.textContent = ev.target.response;
+               }).then(function(res) {
+                       out.textContent = res;
                }).catch(function(err) {
                        ui.addNotification(null, E('p', [ err ]))
                }).finally(function() {